package com.evil.application.pojo.dto.form.control.code;

import com.alibaba.fastjson.JSON;
import com.evil.application.pojo.dto.form.control.code.config.ControlSelectConfigDTO;
import com.evil.application.pojo.entity.ApplicationFormControl;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 成员选择器-表单控件实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class DeptSelControlDTO extends ControlDTO {

    public static final String[] ignoreProperties = new String[]{"controlSelectConfig", "memberDftValueDTO"};

    /**
     * 成员选择控件：默认已选择
     */
    private ControlSelectConfigDTO controlSelectConfig;

    public DeptSelControlDTO(ApplicationFormControl applicationFormControl) {
        super(applicationFormControl, ignoreProperties);

        if (StringUtils.isNotBlank(applicationFormControl.getControlSelectConfig())) {
            this.controlSelectConfig = JSON.parseObject(applicationFormControl.getControlSelectConfig(), ControlSelectConfigDTO.class);
        }
    }
}
